package com.bjpowernode.beans;
import com.bjpowernode.exception.MyRangeException;
public class Stu {
    int id;
    String name;
    String sex;
    String age;
    float score;

    //TODO stu属性验证
    public void validation() throws MyRangeException {
        if(this.getName().length()<1 || this.getName().length()>6){
            throw new MyRangeException("姓名必须是1-6个字符");
        }
        if(this.getScore()<0 || this.getScore()>100){
            throw new MyRangeException("分数必须是0-100");
        }
    }

    public Stu(int id, String name, String sex, String age, float score) {
        this.id = id;
        this.name = name;
        this.sex = sex;
        this.age = age;
        this.score = score;
    }

    public Stu() {
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {


        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public float getScore() {
        return score;
    }

    public void setScore(float score) {
        this.score = score;
    }

    @Override
    public String toString() {
        return "Stu{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", age='" + age + '\'' +
                ", score=" + score +
                '}';
    }
}
